package final2107.day11;

import java.io.*;

public class ConvertStream {
    public static void main(String[] args) throws IOException {
        //创建输入输出流对象
        InputStreamReader isr = new InputStreamReader(
                new FileInputStream("a.java"));
        OutputStreamWriter osw = new OutputStreamWriter(
                new FileOutputStream("acopy2.java"));

        //按照单个字符复制
//        int ch=-1;
//        while ((ch=isr.read())!=-1){
//            osw.write(ch);
//        }
        //按照字符数组复制
//        char[] chs = new char[100];
//        int len=-1;
//        while ((len=isr.read(chs))!=-1){
//            osw.write(chs,0,len);
//        }

        //按照字符数组读取并打印
        char[] chs = new char[50];
        int len=-1;
        while((len=isr.read(chs))!=-1){
            System.out.print(new String(chs,0,len));
        }

        isr.close();
        osw.close();
        /*
        练习：按照单个字符复制
            按照字符数组复制
            按照字符数组读取，将内容打印到控制台
         */
    }
}
